package cn.classTest.mall.config;

import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

@Configuration
public class ShiroConfig {
    @Bean
    public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager) {
        ShiroFilterFactoryBean filter = new ShiroFilterFactoryBean();
        filter.setSecurityManager(securityManager);

        Map<String, String> map = new HashMap<>();
        map.put("/static/**","anon");
        map.put("/login","anon");
        map.put("/static/login.html","anon");
        map.put("/favicon.ico","anon");
        map.put("/logout","logout");
        map.put("/**","authc");
        filter.setFilterChainDefinitionMap(map);
        filter.setLoginUrl("/static/login.html");
        return filter;
    }
}
